<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


    <title>管理员登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">

    <!-- 引入 layui.js -->
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.19.0/js/md5.js"></script>

</head>
<body background="" style="background-color: #56baed;">


<div class="layui-container">
    <br><br><br><br>
    <div class="layui-row" style="text-align: center">


        <div >
            <div class="layui-panel">
                <div style="padding: 30px;width: auto;height: auto;">登录</div>

                <br><br>
                <div >
                    <label>请输入用户名&nbsp;</label>
                    <div class="layui-input-inline">
                        <input id="userID" type="text" name="title" required  lay-verify="required" placeholder="请输入用户名" autocomplete="on" class="layui-input">
                    </div>
                </div>
                <br><br>
                <div >
                    <label>请输入密码&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <div class="layui-input-inline">
                        <input id="password" type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <br><br>
                <button type="button" class="layui-btn layui-btn-normal" onclick="loginAndVarify()">登录</button>
                <br><br><br>
            </div>
        </div>

    </div>

</div>

<script type="text/javascript">
    function loginAndVarify() {
        var userID = $("#userID").val().trim()
        var password = $("#password").val().trim()
        if(password.length === 0) {
            alert("密码不能为空")
        }else{
            var data = {
                id: userID,
                passwd: password
            }
            $.ajax({
                url: "login",
                data: data,
                type:"post",
                success:function(resp) {
                    if(resp === true) {
                        alert("登录成功!将进行自动跳转...");
                        let timeout = setTimeout(function ()  {
                            window.location.href="/getManager";
                        },3000)
                    }else {
                        alert("登录失败！");
                    }
                },
                error:function(){
                    alert("服务器出现错误,请稍后再试")
                }
            })
        }

    }
</script>
</body>
</html>